package admin.controllers;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import admin.models.DomainModel;

import entities.Domain;

public class ProcessBlacklistDomainServlet extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException {
		HttpSession session = request.getSession();
		
		String action = (String) request.getParameter("action");
		String strIds = (String) request.getParameter("ids");
		
		DomainModel domainModel = DomainModel.getInstance();
		Domain domain = new Domain();
		
		String[] ids = strIds.split(",");
		for (int i = 0; i < ids.length; i++) {
	        if (!ids[i].isEmpty()) {
	        	domain = domainModel.get(ids[i]);
	        	if (domain != null) {
	        		domain.setStatus(1);
	        		domainModel.insert(domain);
	        	}
	    	}
	    }
		
		if (ids.length > 0) {
			session.setAttribute("success", "Delete success domain " + strIds);
		}
		
	}
}
